@extends('admin.layout')

@section('title')栏目管理@endsection

@section('content')
    <div class="page clearfix">

        <ol class="breadcrumb breadcrumb-small">
            <li>后台首页</li>
            <li><a href="{{ url('admin/article') }}">系统设置</a></li>
            <li><a href="{{ url('admin/article/create') }}">七牛设置</a></li>
        </ol>
        <div class="page-wrap">


            <div class="container">
                <form action="{{ url('admin/QiniuConfig') }}" method="post" class="form-horizontal">
                    <input type="hidden" name="_token" value="{{ csrf_token() }}">


                    <div class="navbar navbar-default"><p class="navbar-text"><strong>基础配置</strong></p></div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">accessKey *</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="accessKey" value="{{ $config['accessKey'] }}" required/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">secretKey *</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="secretKey" value="{{ $config['secretKey'] }}" required/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">七牛空间域名 *</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="download" value="{{ $config['download'] }}" required/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">允许最大上传（单位M）</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="max_size" value="{{ $config['max_size'] }}" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">失败重试次数</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="max_retries" value="{{ $config['max_retries'] }}">
                        </div>
                    </div>



                    <div class="navbar navbar-default"><p class="navbar-text"><strong>水印配置</strong></p></div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">水印开关</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="isWaterMark">
                                <option value="1" @if($config['isWaterMark'] == 1) selected @endif>开启</option>
                                <option value="0" @if($config['isWaterMark'] == 0) selected @endif>关闭</option>
                            </select>
                        </div>
                    </div>



                    <div class="form-group">
                        <label class="control-label col-sm-2">水印模式</label>
                        <div class="col-sm-10">
                            <select class="form-control Wmode"  name="Wmode">
                                <option value="1" @if($config['Wmode'] == 1) selected @endif>图片模式</option>
                                <option value="2" @if($config['Wmode'] == 2) selected @endif>文字模式</option>
                            </select>
                        </div>
                    </div>


                    <div class="water @if($config['Wmode'] == 2 ) hide @endif">
                        <div class="form-group">
                            <label class="control-label col-sm-2">水印图片地址</label>
                            <div class="col-sm-10">
                                <input class="form-control" id="img" name="Wimage" value="{{ $config['Wimage'] }}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">图片预览</label>
                            <div class="col-sm-10">
                                <img class="img img-thumbnail" id="thumb"  src="{{ $config['Wimage'] }}" />
                            </div>
                        </div>
                    </div>
                    <div class="water @if($config['Wmode'] == 1 ) hide @endif">

                        <div class="form-group">
                            <label class="control-label col-sm-2">水印文字</label>
                            <div class="col-sm-10">
                                <input class="form-control" name="Wtext" value="{{ $config['Wtext'] }}"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">水印大小</label>
                            <div class="col-sm-10">
                                <input class="form-control" name="Wfontsize" value="{{ $config['Wfontsize'] }}"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">水印字体</label>
                            <div class="col-sm-10">
                                <input class="form-control" name="Wfont" value="{{ $config['Wfont'] }}"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">水印颜色</label>
                            <div class="col-sm-10">
                                <input class="form-control" name="Wfill" value="{{ $config['Wfill'] }}"/>
                            </div>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">水印透明度</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Wdissolve" value="{{ $config['Wdissolve'] }}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">水印位置</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="Wgravity">
                                @foreach($Wgravity as $item)
                                    <option value="{{ $item }}" @if($config['Wgravity'] == $item) selected @endif>{{ $item }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">横轴边距</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Wdx" value="{{ $config['Wdx'] }}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">纵轴边距</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Wdy" value="{{ $config['Wdy'] }}"/>
                        </div>
                    </div>

                    <div class="navbar navbar-default"><p class="navbar-text"><strong>缩略图配置</strong></p></div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">缩略图开关</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="isThumb">
                                <option value="1" @if($config['isThumb'] == 1) selected @endif>开启</option>
                                <option value="0" @if($config['isThumb'] == 0) selected @endif>关闭</option>
                            </select>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">缩略模式</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="Tmode">
                                <option value="1" @if($config['Tmode'] == 1) selected @endif>模式1</option>
                                <option value="1" @if($config['Tmode'] == 2) selected @endif>模式2</option>
                                <option value="1" @if($config['Tmode'] == 3) selected @endif>模式3</option>
                                <option value="1" @if($config['Tmode'] == 4) selected @endif>模式4</option>
                                <option value="1" @if($config['Tmode'] == 5) selected @endif>模式5</option>
                                <option value="1" @if($config['Tmode'] == 6) selected @endif>模式6</option>
                            </select>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">W</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Tw" value="{{ $config['Tw'] }}"/>
                            <span class="help-block">缩略模式决定含义</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">H</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Th" value="{{ $config['Th'] }}"/>
                            <span class="help-block">缩略模式决定含义</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">图像质量</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Tq" value="{{ $config['Tq'] }}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">输出缩略图格式</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Tformat" value="{{ $config['Tformat'] }}"/>
                        </div>
                    </div>


                    <div class="navbar navbar-default"><p class="navbar-text"><strong>高级处理</strong></p></div>

                    <div class="alert alert-danger">
                        <p>
                            注意：如果您不是图像处理专业人员，我们强烈建议您关闭高级处理
                        </p>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">高级处理开关</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="isSenior">
                                <option value="1" @if($config['isSenior'] == 1) selected @endif>开启</option>
                                <option value="0" @if($config['isSenior'] == 0) selected @endif>关闭</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">是否根据原图自动旋正</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="Mautoorient">
                                <option value="true" @if($config['Mautoorient'] == true) selected @endif>是</option>
                                <option value="false" @if($config['Mautoorient'] == false) selected @endif>否</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">是否去除图片中的元信息</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="Mstrip">
                                <option value="true" @if($config['Mstrip'] == true) selected @endif>是</option>
                                <option value="false" @if($config['Mstrip'] == false) selected @endif>否</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">缩放操作参数</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Mthumbnail" value="{{ $config['Mthumbnail'] }}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">裁剪操作参数</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Mcrop" value="{{ $config['Mcrop'] }}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-2">裁剪锚点参数</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="Mgravity">
                                @foreach($Wgravity as $item)
                                    <option value="{{ $item }}" @if($config['Mgravity'] == $item) selected @endif>{{ $item }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">图像质量</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Mquality" value="{{ $config['Mquality'] }}"/>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">旋转角度</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Mrotate" value="{{ $config['Mrotate'] }}"/>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">输出格式</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Mformat" value="{{ $config['Mformat'] }}"/>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="control-label col-sm-2">高斯模糊参数</label>
                        <div class="col-sm-10">
                            <input class="form-control" name="Mblur" value="{{ $config['Mblur'] }}"/>
                        </div>
                    </div>


                    <div class="form-group" align="center">
                        <input class="btn btn-default" type="submit" value="保存配置" />
                    </div>

                </form>
            </div>

            <div class="panel-footer">
                <p>
                    温馨提示：该页全部配置，均由七牛提供，如果您对配置存在不理解的地方，可移步至<a target="_blank" href="http://developer.qiniu.com/code/v6/sdk/javascript.html">七牛官方API文档</a>查看
                </p>
            </div>




        </div>
    </div>
@endsection

@section('javascript')
    <script>
        $(function()
        {
            /*水印模式切换*/
            $('.Wmode').change(function()
            {
                var index = parseInt($(this).val()) - 1;
                $('.water').eq(index).removeClass('hide').siblings('.water').addClass('hide');
            });
            /*水印图片预览*/
            $('#img').blur(function()
            {
                $('#thumb').attr('src',$(this).val());
            });
        })
    </script>
@endsection
